#include <iostream>
#include <string.h>
#include <math.h>
#define long long int
using namespace std;



struct item{
	int weight,value,num;
};


struct item2{
	int a,b,c;
	int cac(int x){
		return x*x*a+x*b+c;
	}
};



signed main(){
	int t,n,m;
	cin>>n>>m>>t;
	int dp[t+1];
	item a[n];
	item2 b[m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++)
		cin>>a[i].weight>>a[i].value>>a[i].num;
	for(int i=0;i<m;i++)
		cin>>b[i].a>>b[i].b>>b[i].c;
	for(int i=1;i<=n;i++)
		for(int j=t;j>=0;j--)
			for(int k=0;k<=min(a[i-1].num,j/a[i-1].weight);k++)
				dp[j] = max(dp[j],dp[j-k*a[i-1].weight]+k*a[i-1].value);
//	cout<<1;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=t;j++){
			dp[j] = max(dp[j],dp[j-1]+b[i-1].cac(1));
//				cout<<"i)"<<i<<" j)"<<j<<" dp)"<<dp[j]<<endl;
				cout<<dp[j]<<" ";
		}
		cout<<endl;
	}
	cout<<dp[t];
	return 0;
}
